package num01;

import java.util.HashMap;

public class LiangShuZHiHe02 {
    public static int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> hashMap = new HashMap<>();

        int n = nums.length;
        for (int i = 0; i < n; i++) {
            if (hashMap.containsKey(target-nums[i])){
                return new int[]{i,hashMap.get(target-nums[i])};
            }
            hashMap.put(nums[i], i);
        }

        return new int[0];

    }
    public static void main(String[] args) {
        int[] ints = new int[]{3,2,4};
        int[] ints1 = twoSum(ints, 6);
        System.out.println(ints1.toString());

    }
}
